using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Linq.Expressions;

namespace Infrastructure.Interface
{
    /// <summary>
    /// 定义查找实体的接口
    /// <remarks></remarks>
    /// </summary>
    /// <typeparam name="T">实体类型</typeparam>
    public interface IFindable<T> where T : IEntity
    {
        /// <summary>
        /// 查找对象
        /// </summary>
        /// <param name="id">实体的ID</param>
        /// <returns></returns>
        T Find(Guid id);

        /// <summary>
        /// 获取所有实体对象
        /// </summary>
        /// <typeparam name="TNew">投影类型</typeparam>
        /// <param name="where">条件</param>
        /// <param name="selector">选择器</param>
        /// <param name="orderByString">排序字符串,为null则不排序</param>
        /// <returns></returns>
        List<TNew> FindAll<TNew>(Expression<Func<T, bool>> where, Expression<Func<T, TNew>> selector, string orderByString) where TNew : class;

        /// <summary>
        /// 获取前N条数据
        /// </summary>
        /// <typeparam name="TNew">投影类型</typeparam>
        /// <param name="where">条件</param>
        /// <param name="selector">选择器</param>
        /// <param name="orderByString">排序字符串</param>
        /// <param name="count">选择记录条数</param>
        /// <returns></returns>
        List<TNew> FindTop<TNew>(Expression<Func<T, bool>> where, Expression<Func<T, TNew>> selector, string orderByString, int count) where TNew : class;
    }
}
